var pricesforclient = (function (e){
    var initials = false,cID;
    e.loadPricedForClient = function(clientID){
        cID = clientID;
        dataBase.getPricesList(cID, function(data){
            var i, num = data.length, str=[];
            for(i=0;i<num;i+=1){
                str.push("<li ClientPriceID='" + data[i].PriceID + "'><a style='display: inline-block; padding: 14px 14px 0px 14px; font-size: 14px;'>" +
                    data[i].Services + "</a>" +
                "<span style='font-size: 11px;display: block;padding-left: 20px;padding-bottom: 14px;'>" + data[i].Name +
                ": " + data[i].Price + " " + data[i].Currency + "</span></li>")
            }
            $("#lstPricesForClient").html(str.join('')).listview('refresh');
        });
        e.init();
    };
    e.init = function(){
        if(!initials){
            $("#btnAddPriceForClient").click(function(){
                priceforclient.initAddNewContactPrice(cID);
                $.mobile.changePage("#pnPriceFC");
                //windows.showPage("pnPriceForClient","pnPriceFC")
            });
            $("#lstPricesForClient").delegate("li", "click", function () {
                var cpID = parseInt($(this).attr("ClientPriceID"));
                priceforclient.editAddNewContactPrice(cpID, cID);
                $.mobile.changePage("#pnPriceFC");
                windows.showPage("pnPriceForClient","pnPriceFC");
            });
            $("#btnPriceForClientBack").click( function (){
                //addnewclient.edit(cID);
                $.mobile.changePage("#pnClient");
                //windows.return();
            });
        }
        initials = true;
    };
    return e;
}(pricesforclient || {}));
